package com.example.langchaindemo.controller;

import com.example.langchaindemo.aiservice.ConsultantService;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class WenController {
//    @Autowired
//    private OpenAiChatModel openAiChatModel;
//    @RequestMapping("/chat")
//    public String chat(String question){
//        return openAiChatModel.chat(question);
//    }
    @Autowired
    ConsultantService consultantService;
//    @RequestMapping("/chat")
//    public String chat(String question){
//        return consultantService.ask(question);
//    }
    //流式输出调用
    @RequestMapping(value = "/chat",produces = "text/html;charset=UTF-8")
    public Flux<String> chat(String memoryId,String message){
        return consultantService.askStreaming(memoryId,message);
    }
}
